<?php

/**
 * Subclass for representing a row from the 'articulo' table.
 *
 * 
 *
 * @package lib.model
 */ 
class Articulo extends BaseArticulo
{
  public function getReordenacion(){
    return ($this->getExistencia() <= $this->getReorden()) ? "Reorden" : false;
  }
  
	public function __toString(){
		return $this->getCodigo();
		
	}
	
	public function delete(PropelPDO $con = null){
	if ($this->isDeleted()) {
      throw new PropelException("This object has already been deleted.");
    }

    if ($con === null) {
      $con = Propel::getConnection(ArticuloPeer::DATABASE_NAME);
    }

    try {
      $con->beginTransaction();
      //ArticuloPeer::doDelete($this, $con);
      //$this->setDeleted(true);
      if($this->getFoto() != 'none.png')
        unlink(sfConfig::get('sf_root_dir').'/web/images/fotos/'.$this->getFoto());
      $con->commit();
    } catch (PropelException $e) {
      $con->rollBack();
      throw $e;
    }
    parent::delete($con);
	}
}
